﻿//===========================[ 7 / 20 / 2011 LVI ]=============================
//				Copyright c Vitaly Lyaschenko <SkyChameleon@gmail.com>
// 								Header file
// Purpose: форматы вертексов
// P - позиция вершины
// N - нормаль вершины
// T - текстурные координаты UV
// B - бинормаль |-
//=============================================================================
#pragma once

#include "mathlib.h"
//using namespace _mtl;

#define    VERT_POSITION   1
#define    VERT_NORMAL     2
#define    VERT_TANGENT    3
#define    VERT_BINORMAL   4
#define    VERT_TEXCOORD   5
#define    VERT_COLOR      6

enum ELEMENTS
{
	XYZ      = 1,
	Normal   = 2,
	Tangent  = 3,
	Binormal = 4,
	Texcoord = 5,
	Color    = 6,
};

struct Vertex_p // position
{

	union
	{
		struct
		{ 
			float x, y, z; 
		};
		float vrt[2];
	};
};

struct Vertex_pc // position | color
{
	vec3 pos;
	vec3 color;
};

struct Vertex_pt // position | texture coor.
{
	union
	{
		struct
		{         
			float x, y, z;
			float tu1, tv1;
		};
		float vrt[4];
	};
};

struct Vertex_pn // position | normal
{
	union
	{
		struct
		{
			float x, y, z;
			float nx, ny, nz;
		};
		float vrt[5];
	};
};

struct Vertex_PNexTbt // P - position | N - normal | exT - extended texture coor. | b - binormal | t - tangent
{
	union
	{
		struct
		{
			float x, y, z;
			float nx, ny, nz;
			float u1, v1;
			float u2, v;
			float bx, by, bz;
			float tx, ty, tz;
		};
		float vrt[16];
	};
};

struct Vertex_PNT // position | normal | texture coor.
{
	union
	{
		struct
		{
			float x, y, z;
			float nx, ny, nz;
			float u, v;
		};
		float vrt[7];
	};
};

struct Vertex_PNCT // position | normal | color | texture coor.
{
	union
	{
		struct
		{
			float x, y, z;
			float nx, ny, nz;
			float r, g, b;
			float u, v;
		};
		float vrt[7];
	};
};

struct Vertex_pt2 // position |  texture coor.1 |  texture coor.2
{
	union
	{
		struct
		{
			float x, y, z;
			float u1, v1;
			float u2, v2;
		};
		float vrt[6];
	};
};

struct Vertex_pnbt // position | normal | binormal | texture coor.
{
	union
	{
		struct
		{
			float x, y, z;
			float nx, ny, nz;
			float bnx, bny, bnz; // 
			float u, v;
		};
		float vrt[10];
	};
};

struct Vertex_pEx // extended
{
	union
	{
		struct
		{
			float x, y, z, w;
		};
		float vrt[3];
	};
};

struct Vertex_pEx_t
{
	union
	{
		struct
		{
			float x, y, z, w;
			float tu1, tv1;
		};
		float vrt[5];
	};
};

struct Vertex_pEx_tEx
{
	union
	{
		struct
		{
			float x, y, z, w;
			float tu1, tv1, tw;
		};
		float vrt[6];
	};
};

inline bool operator == ( const Vertex_PNT &Lv, const Vertex_PNT &Rv )
{
	if( Lv.x == Rv.x )		// TODO: добавить epsilon
		if( Lv.y == Rv.y )
			if( Lv.z == Rv.z )
				if( Lv.u == Rv.u )
					if( Lv.v == Rv.v )
						return true;
	return false;
}

inline bool operator != ( const Vertex_PNT &Lv, const Vertex_PNT &Rv )
{
	if( Lv.x != Rv.x )		// TODO: добавить epsilon
		return true;
	if( Lv.y != Rv.y )
		return true;
	if( Lv.z != Rv.z )
		return true;
	return false;
}
